package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.UserWorkerInfo;
import cn.anxingongyou.anxin.mapper.UserWorkerInfoMapper;
import cn.anxingongyou.anxin.service.UserWorkerInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserWorkerInfoServiceImpl implements UserWorkerInfoService {

    private final UserWorkerInfoMapper userWorkerInfoMapper;
    @Autowired
    public UserWorkerInfoServiceImpl(UserWorkerInfoMapper userWorkerInfoMapper) {
        this.userWorkerInfoMapper = userWorkerInfoMapper;
    }

    @Override
    public int insert(UserWorkerInfo userWorkerInfo) {
        return userWorkerInfoMapper.insertSelective(userWorkerInfo);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return userWorkerInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(UserWorkerInfo userWorkerInfo) {
        return userWorkerInfoMapper.updateByPrimaryKeySelective(userWorkerInfo);
    }

    @Override
    public UserWorkerInfo selectOne(UserWorkerInfo userWorkerInfo) {
        return userWorkerInfoMapper.selectOne(userWorkerInfo);
    }

    @Override
    public UserWorkerInfo selectOneByPrimaryKey(Long id) {
        return userWorkerInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<UserWorkerInfo> page(int pageNum, int pageSize, UserWorkerInfo userWorkerInfo) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<UserWorkerInfo> list = userWorkerInfoMapper.select(userWorkerInfo);
        PageInfo<UserWorkerInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
